The @Grab annotation in Groovy supports two formats for specifying dependencies: a verbose format with named parameters and a concise
shorthand format using the Maven coordinate style.
The verbose format requires explicitly naming each parameter: @Grab(group='org.springframework', module='spring-orm',
version='5.2.8.RELEASE')
The shorthand format uses the familiar Maven coordinate pattern: @Grab('org.springframework:spring-orm:5.2.8.RELEASE')
When only the basic dependency information (group, module, version) is needed, the shorthand notation offers several advantages:
- Improved readability: The shorthand format is more compact and easier to scan visually
- Familiar syntax: It follows the same pattern used in Maven, Gradle, and other build tools
- Reduced verbosity: Less code to write and maintain
- Consistency: Aligns with common practices in the Java ecosystem
The verbose format should be reserved for cases where additional parameters are needed, such as classifier, transitive,
changing, or conf options.